package com.emergency.engine.dao;

import com.emergency.engine.domain.PlanScore;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * Created by asus on 2020/3/23.
 */
public interface PlanScoreDao extends JpaRepository<PlanScore,String>, JpaSpecificationExecutor<PlanScore> {
    //根据场景Id查找打分方案
    @Query(value ="SELECT * FROM bus_plan_score WHERE scenar_id = ?1 AND plan_id = ?2", nativeQuery=true)
    PlanScore findAllByPlanAndScenarId(Long scenarId, Long planId);

    //查询打分方案表对应的Id方案排序
    @Query(value ="SELECT * FROM bus_plan_score WHERE plan_id IN (?1) ORDER BY p_score", nativeQuery=true)
    List<PlanScore> findAllByPlanScore(List planId);

}
